<!DOCTYPE html>
<html class="x-admin-sm">
<head>
    <meta charset="UTF-8">
    <title>宇成建筑</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <link rel="stylesheet" href="../statics/css/font.css">
    <link rel="stylesheet" href="../statics/plugins/layui/css/layui.css">
    <link rel="stylesheet" href="../statics/css/xadmin.css">
    <link rel="stylesheet" href="../statics/css/style.css">
    <style>
        .layui-card-body{
            height:inherit;
        }
    </style>
</head>

<body class='labelAuto'>
<div class="x-nav">
        <span class="layui-breadcrumb">
            <a href="welcome.html">首页</a>
            <a href="javascript:;">审批</a>
            <a href="javascript:;">审批</a>
            <a href="javascript:;">施工量价</a>
            <a><cite>施工量价（班组）</cite></a>
        </span>
    <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right"
       onclick="location.reload()" title="刷新">
        <i class="layui-icon layui-icon-refresh" style="line-height:30px"></i>
    </a>
    <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right;margin-right:10px"
       onclick="window.history.go(-1)" title="后退">
        <i class="iconfontBlod" style="line-height:30px">&#xe74f;</i>
    </a>
</div>
<div class="layui-fluid">
    <div class="layui-d layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">
                <!--                <div class="layui-card-body">暂无数据</div>-->
                <div class="layui-card-body">
                    <!--                    <div class="layui-collapse" lay-accordion>-->
                    <!--                        <div class="layui-colla-item">-->
                    <!--                            <h2 class="layui-colla-title">shigongqu</h2>-->
                    <!--                            <div class="layui-colla-content">-->
                    <!--                                <h3>cesshshs</h3>-->
                    <!--                                <h3>cesshshs</h3>-->
                    <!--                                <h3>cesshshs</h3>-->
                    <!--                            </div>-->
                    <!--                        </div>-->
                    <!--                    </div>-->
                </div>
            </div>
        </div>

    </div>
</div>
</body>
<script src="../statics/plugins/layui/layui.js" charset="utf-8"></script>
<script src='../statics/plugins/jQuery-3.2.1/jquery-3.2.1.min.js'></script>
<script type="text/javascript" src="../statics/plugins/X-admin/xadmin.js"></script>
<script type="text/javascript" src="../statics/js/public.js?v=1129"></script>
<script type="text/javascript">
    layui.use(['element'], function () {
        var element = layui.element
        // 异步数据加载
        var approvalId = getQueryString('approvalId');
        var projectId = getQueryString('projectId');
        var sectionId = getQueryString('sectionId');
        var professionId = getQueryString('professionId');
        var month = getQueryString('month');
        var data = [];
        element.render('collapse');
        $.ajax({
            type:"post",
            url:url+'/approval/approval/approvalDataAssignmentInfo',
            async:false,
            data:{
                approvalId:approvalId,
                projectId:projectId,
                sectionId:sectionId,
                professionId:professionId,
                month:month,
                token:getParam('token')
            },
            success:function(r){
                if(r.code == 100000){
                    data = r.data;
                }else{
                    tips('审批',r)
                }
            }
        });

        var html = `<div class="layui-collapse" lay-accordion>`
        for(var i=0;i<data.length;i++){
            html+=`<div class="layui-colla-item">
                            <h2 class="layui-colla-title">班组：${data[i].groupName}&nbsp;&nbsp;&nbsp;&nbsp;${data[i].sum}元</h2>
                            <div class="layui-colla-content">`
            html +=`<table class="layui-table">
                        <thead>
                            <tr>
                                <th>编号</th>
                                <th>施工项</th>
                                <th>工程量</th>
                                <th>单位</th>
                                <th>单价</th>
                                <th>总价</th>
                                <th>批次</th>
                                <th>备注</th>
                                <th>录入人</th>
                                <th>记录时间</th>
                                <th>审核状态</th>
                            </tr>
                        </thead>
                        <tbody>`;
            for(var j=0;j<data[i].assignment.length;j++){
                html+=`<tr>
                           <td>${j+1}</td>
                           <td>${data[i].assignment[j].assignmentName}</td>
                           <td>${data[i].assignment[j].amount}</td>
                           <td>${data[i].assignment[j].unitName}</td>
                           <td>${data[i].assignment[j].price}</td>
                           <td>${Number(data[i].assignment[j].price)*Number(data[i].assignment[j].amount)}</td>
                           <td>${data[i].assignment[j].batch}</td>
                           <td>${data[i].assignment[j].remark?data[i].assignment[j].remark:''}</td>
                           <td>${data[i].assignment[j].adminName}</td>
                           <td>${data[i].assignment[j].completeTime}</td>
                           <td>${status_show(data[i].assignment[j].status)}</td>
                       </tr>`
            }
            html+=`</tbody></table><br/>`;

            html +=`<table class="layui-table">
                        <thead>
                            <tr>
                                <th>编号</th>
                                <th>姓名</th>
                                <th>工号</th>
                                <th>角色</th>
                                <th>分账金额</th>
                                <th>审核状态</th>
                            </tr>
                        </thead>
                        <tbody>`;
            for(var k=0;k<data[i].separate.length;k++){
                var total = 0;
                var status = 2;
                for(var l=0;l<data[i].separate[k].accounts.length;l++){
                    total+=Number(data[i].separate[k].accounts[l].account);
                    if (data[i].separate[k].accounts[l].status == 4){
                        status = 4;
                    }
                }
                html+=`<tr>
                           <td>${k+1}</td>
                           <td>${data[i].separate[k].employeeName}</td>
                           <td>${data[i].separate[k].jobNumber}</td>
                           <td>${data[i].separate[k].isLeader?'组员':'组长'}</td>
                           <td>${data[i].separate[k].accounts.length==0?'':total}</td>
                           <td>${status==2?'待审核':status==3?'已通过':status==4?'已驳回':''}</td>
                       </tr>`
            }
            html+=`</tbody></table>`;
            html+= `</div></div>`
        }
        html += `</div>`
        $('.layui-card-body').empty().html(html);
        element.render('collapse');

        function status_show($status){
            switch ($status) {
                case 0:
                    $str = '待提交';
                    break;
                case 1:
                    $str = '待审核';
                    break;
                case 2:
                    $str = '审核中';
                    break;
                case 3:
                    $str = '已通过';
                    break;
                case 4:
                    $str = '未通过';
                    break;
            }
            return $str;
        }
    });

</script>
</html>